package com.kkkkkba.search.DataSource;

import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptException;
import java.util.Arrays;

public class Main {
   static final private String html =
            "<script type=\"text/javascript\">\n" +
            "        $(function () {\n" +
            "            const url = 'https://other-player-ra01-sycdn.kuwo.cn/87171eed42a7e77c4147b0c503f12078/650fc96e/resource/n3/320/74/27/4113470514.mp3?bitrate$320&amp;format$mp3&amp;type$convert_url2'.replace(new RegExp('&amp;', 'g'), \"&\");\n" +
            "            const ap = new APlayer({\n" +
            "                container: document.getElementById('aplayer'),\n" +
            "                autoplay: false,\n" +
            "                theme: '#0e90d2',\n" +
            "                lrcType: 1,\n" +
            "                preload: 'none',\n" +
            "                // loop: 'none',\n" +
            "                order: 'list',\n" +
            "            });\n" +
            "            ap.on('listswitch', function () {\n" +
            "                layer.tips('点击这里播放', '.aplayer-button', {\n" +
            "                    tips: [3, '#FF5722'],\n" +
            "                });\n" +
            "            });\n" +
            "            \n" +
            "                        \n" +
            "            $('#btn-download-mp3').attr('href', 'http://other-player-ra01-sycdn.kuwo.cn/87171eed42a7e77c4147b0c503f12078/650fc96e/resource/n3/320/74/27/4113470514.mp3?bitrate$320&amp;format$mp3&amp;type$convert_url2');\n" +
            "            \n" +
            "            var name = '稻香' + '-' + '周杰伦';\n" +
            "            $('#btn-download-mp3').attr('download', name + '.mp3');\n" +
            "            $('#btn-download-lrc').attr('download', name + '.lrc');\n" +
            "            var is_error = false;\n" +
            "            ap.on('error', function () {\n" +
            "                is_error = true;\n" +
            "                console.log(ap.audio.currentSrc)\n" +
            "                $.post('/api/err_music', {id: 112019});\n" +
            "            });\n" +
            "            \n" +
            "            \n" +
            "                        \n" +
            "            $('#btn-download-mp3').click(function () {\n" +
            "                \n" +
            "                                \n" +
            "                //\n" +
            "                if (is_error) {\n" +
            "                    layer.msg('当前歌曲解析出错，暂不能下载', {offset: '100px', icon: 0});\n" +
            "                    return false;\n" +
            "                }\n" +
            "                                    $.ajaxSettings.async = false;\n" +
            "                let adshow = false;\n" +
            "                $.get(\"/api/ad_handle\", function (data, status) {\n" +
            "                    if (data.code != 0) {\n" +
            "                        return true;\n" +
            "                    } else {\n" +
            "                        $('#ad-modal-body').html(data.msg);\n" +
            "                        $('#ad-modal').modal('toggle');\n" +
            "                        adshow = true;\n" +
            "                        return false;\n" +
            "                    }\n" +
            "                });\n" +
            "                $.ajaxSettings.async = true;\n" +
            "                if (adshow) return false;\n" +
            "                                                        \n" +
            "                if (is_qq_wx_tb()) {\n" +
            "                    return false;\n" +
            "                }\n" +
            "                \n" +
            "                $.post(\"/api/download_log\",\n" +
            "                    {\n" +
            "                        music_id: '112019'\n" +
            "                    });\n" +
            "\n" +
            "            });\n" +
            "            \n" +
            "            ap.list.add([{\n" +
            "                name: '稻香',\n" +
            "                artist: '周杰伦',\n" +
            "                url: url,\n" +
            "                cover: 'https://img4.kuwo.cn/star/albumcover/120/72/44/3648126291.jpg',\n" +
            "                lrc: '\"[00:3.48]\\u7a3b\\u9999 - \\u5468\\u6770\\u4f26 \\u0026\\u6797\\u4fca\\u6770\\n[00:8.64]\\u8bcd\\uff1a\\u5468\\u6770\\u4f26\\n[00:15.6]\\u66f2\\uff1a\\u5468\\u6770\\u4f26\\n[00:20.27]\\u5bf9\\u8fd9\\u4e2a\\u4e16\\u754c\\u5982\\u679c\\u4f60\\u6709\\u592a\\u591a\\u7684\\u62b1\\u6028\\n[00:23.52]\\u8dcc\\u5012\\u4e86\\u5c31\\u4e0d\\u6562\\u7ee7\\u7eed\\u5f80\\u524d\\u8d70\\n[00:26.56]\\u4e3a\\u4ec0\\u4e48\\u4eba\\u8981\\u8fd9\\u4e48\\u7684\\u8106\\u5f31\\u5815\\u843d\\n[00:30.79]\\u8bf7\\u4f60\\u6253\\u5f00\\u7535\\u89c6\\u770b\\u770b\\n[00:32.37]\\u591a\\u5c11\\u4eba\\u4e3a\\u751f\\u547d\\u5728\\u52aa\\u529b\\u52c7\\u6562\\u7684\\u8d70\\u4e0b\\u53bb\\n[00:36.38]\\u6211\\u4eec\\u662f\\u4e0d\\u662f\\u8be5\\u77e5\\u8db3\\n[00:38.84]\\u73cd\\u60dc\\u4e00\\u5207\\u5c31\\u7b97\\u6ca1\\u6709\\u62e5\\u6709\\n[00:43.47]\\u8fd8\\u8bb0\\u5f97\\u4f60\\u8bf4\\u5bb6\\u662f\\u552f\\u4e00\\u7684\\u57ce\\u5821\\n[00:46.96]\\u968f\\u7740\\u7a3b\\u9999\\u6cb3\\u6d41\\u7ee7\\u7eed\\u5954\\u8dd1\\n[00:49.88]\\u5fae\\u5fae\\u7b11 \\u5c0f\\u65f6\\u5019\\u7684\\u68a6\\u6211\\u77e5\\u9053\\n[00:55.31]\\u4e0d\\u8981\\u54ed\\u8ba9\\u8424\\u706b\\u866b\\u5e26\\u7740\\u4f60\\u9003\\u8dd1\\n[00:58.72]\\u4e61\\u95f4\\u7684\\u6b4c\\u8c23\\u6c38\\u8fdc\\u7684\\u4f9d\\u9760\\n[01:02.6]\\u56de\\u5bb6\\u5427 \\u56de\\u5230\\u6700\\u521d\\u7684\\u7f8e\\u597d\\n[01:50.93]\\u4e0d\\u8981\\u8fd9\\u4e48\\u5bb9\\u6613\\u5c31\\u60f3\\u653e\\u5f03\\n[01:54.4]\\u5c31\\u50cf\\u6211\\u8bf4\\u7684\\n[01:56.9]\\u8ffd\\u4e0d\\u5230\\u7684\\u68a6\\u60f3\\u6362\\u4e2a\\u68a6\\u4e0d\\u5c31\\u5f97\\u4e86\\n[01:61.95]\\u4e3a\\u81ea\\u5df1\\u7684\\u4eba\\u751f\\u9c9c\\u8273\\u4e0a\\u8272\\n[01:65.87]\\u5148\\u628a\\u7231\\u6d82\\u4e0a\\u559c\\u6b22\\u7684\\u989c\\u8272\\n[01:70.28]\\u7b11\\u4e00\\u4e2a\\u5427\\n[01:72.03]\\u529f\\u6210\\u540d\\u5c31\\u4e0d\\u662f\\u76ee\\u7684\\n[01:75.27]\\u8ba9\\u81ea\\u5df1\\u5feb\\u4e50\\u5feb\\u4e50\\u8fd9\\u624d\\u53eb\\u505a\\u610f\\u4e49\\n[01:80.22]\\u7ae5\\u5e74\\u7684\\u7eb8\\u98de\\u673a\\n[01:82.5]\\u73b0\\u5728\\u7ec8\\u4e8e\\u98de\\u56de\\u6211\\u624b\\u91cc\\n[01:89.75]\\u6240\\u8c13\\u7684\\u90a3\\u5feb\\u4e50\\n[01:91.83]\\u8d64\\u811a\\u5728\\u7530\\u91cc\\u8ffd\\u873b\\u8713\\u8ffd\\u5230\\u7d2f\\u4e86\\n[01:96.5]\\u5077\\u6458\\u6c34\\u679c\\u88ab\\u871c\\u8702\\u7ed9\\u53ee\\u5230\\u6015\\u4e86\\n[02:01.8]\\u8c01\\u5728\\u5077\\u7b11\\u5462\\n[02:04.58]\\u6211\\u9760\\u7740\\u7a3b\\u8349\\u4eba\\n[02:06.4]\\u5439\\u7740\\u98ce \\u5531\\u7740\\u6b4c \\u7761\\u7740\\u4e86\\n[02:12.13]\\u5348\\u540e\\u5409\\u4ed6\\u5728\\u866b\\u9e23\\u4e2d\\u66f4\\u6e05\\u8106\\n[02:16.52]\\u9633\\u5149\\u6d12\\u5728\\u8def\\u4e0a\\u5c31\\u4e0d\\u6015\\u5fc3\\u788e\\n[02:20.82]\\u73cd\\u60dc\\u4e00\\u5207 \\u5c31\\u7b97\\u6ca1\\u6709\\u62e5\\u6709\\n[02:28.55]\\u8fd8\\u8bb0\\u5f97\\u4f60\\u8bf4\\u5bb6\\u662f\\u552f\\u4e00\\u7684\\u57ce\\u5821\\n[02:34.23]\\u968f\\u7740\\u7a3b\\u9999\\u6cb3\\u6d41\\u7ee7\\u7eed\\u5954\\u8dd1\\n[02:39.02]\\u5fae\\u5fae\\u7b11 \\u5c0f\\u65f6\\u5019\\u7684\\u68a6\\u6211\\u77e5\\u9053\\n[02:48.32]\\u4e0d\\u8981\\u54ed\\u8ba9\\u8424\\u706b\\u866b\\u5e26\\u7740\\u4f60\\u9003\\u8dd1\\n[02:53.8]\\u4e61\\u95f4\\u7684\\u6b4c\\u8c23\\u6c38\\u8fdc\\u7684\\u4f9d\\u9760\\n[02:58.8]\\u56de\\u5bb6\\u5427 \\u56de\\u5230\\u6700\\u521d\\u7684\\u7f8e\\u597d\\n[02:67.98]\\u8fd8\\u8bb0\\u5f97\\u4f60\\u8bf4\\u5bb6\\u662f\\u552f\\u4e00\\u7684\\u57ce\\u5821\\n[02:73.38]\\u968f\\u7740\\u7a3b\\u9999\\u6cb3\\u6d41\\u7ee7\\u7eed\\u5954\\u8dd1\\n[02:78.1]\\u5fae\\u5fae\\u7b11 \\u5c0f\\u65f6\\u5019\\u7684\\u68a6\\u6211\\u77e5\\u9053\\n[02:87.1]\\u4e0d\\u8981\\u54ed\\u8ba9\\u8424\\u706b\\u866b\\u5e26\\u7740\\u4f60\\u9003\\u8dd1\\n[02:92.78]\\u4e61\\u95f4\\u7684\\u6b4c\\u8c23\\u6c38\\u8fdc\\u7684\\u4f9d\\u9760\\n[02:97.55]\\u56de\\u5bb6\\u5427 \\u56de\\u5230\\u6700\\u521d\\u7684\\u7f8e\\u597d\\n\"',\n" +
            "            }]);\n" +
            "            \n" +
            "            $('.expand').click(function () {\n" +
            "                if ($(this).attr('data-status') === 'up') {\n" +
            "                    $('.content-lrc').addClass('height-auto');\n" +
            "                    $(this).attr('data-status', 'down')\n" +
            "                    $(this).text('收起')\n" +
            "                } else {\n" +
            "                    $('.content-lrc').removeClass('height-auto');\n" +
            "                    $(this).attr('data-status', 'up')\n" +
            "                    $(this).text('展开')\n" +
            "                }\n" +
            "            });\n" +
            "\n" +
            "            \n" +
            "            setTimeout('autoScroll(\"#download-log\")', 3500);\n" +
            "        });\n" +
            "        \n" +
            "        function is_qq_wx_tb() {\n" +
            "            var ua = navigator.userAgent.toLowerCase();\n" +
            "            if (ua.match(/MicroMessenger\\/[0-9]/i)) {\n" +
            "                layer.msg(\"微信进入的用户请换用系统自带浏览器重新打开本站才能进行歌曲下载\", {offset: '100px', icon: 7});\n" +
            "                return true;\n" +
            "            }\n" +
            "\n" +
            "            if (ua.match(/QQ\\/[0-9]/i)) {\n" +
            "                layer.msg(\"QQ进入的用户请换用系统自带浏览器重新打开本站才能进行歌曲下载\", {offset: '100px', icon: 7});\n" +
            "                return true;\n" +
            "            }\n" +
            "\n" +
            "            if (ua.match(/tieba\\/[0-9]/i)) {\n" +
            "                layer.msg(\"百度贴吧进入的用户请换用系统自带浏览器重新打开本站才能进行歌曲下载\", {\n" +
            "                    offset: '100px',\n" +
            "                    icon: 7\n" +
            "                });\n" +
            "                return true;\n" +
            "            }\n" +
            "            return false;\n" +
            "        }\n" +
            "        \n" +
            "        function autoScroll(obj) {\n" +
            "            $(obj).find(\"ul\").animate({\n" +
            "                    marginTop: \"-1rem\"\n" +
            "                },\n" +
            "                1000,\n" +
            "                function () {\n" +
            "                    $(this).css({\n" +
            "                        marginTop: \"0\"\n" +
            "                    }).find(\"li:first\").appendTo(this);\n" +
            "                    setTimeout('autoScroll(\"#download-log\")', 3500);\n" +
            "                });\n" +
            "        }\n" +
            "    </script>\n";


    public static void main(String[] args) {

    }

}


